<template>
	<view>
		<view class="card u-m-b-10" v-for="(item, index) in dataArr" :key="index">
			<view class="item u-flex">
				<text class="label text-gray">产品名称：</text>
				<view class="text u-line-1">{{ item.title }}</view>
			</view>
			<view class="item u-flex">
				<text class="label text-gray">产品类别：</text>
				<view class="text u-line-1">{{ item.cateName }}</view>
			</view>
			<view class="item u-flex">
				<text class="label text-gray">单价/积分：</text>
				<view class="text u-line-1">{{ item.specName }}</view>
			</view>
			<view class="item u-flex">
				<text class="label text-gray">备&ensp;注&ensp;一：</text>
				<view class="text u-line-1">{{ item.remark1 || '-' }}</view>
			</view>
			<view class="item u-flex">
				<text class="label text-gray">备&ensp;注&ensp;二：</text>
				<view class="text u-line-1">{{ item.remark2 || '-' }}</view>
			</view>
		</view>


		
		<view class="footer">
			<view class="u-flex u-row-between">
				<text class="text u-flex-1">共计：{{ dataArr.length }} 件商品</text>
				<button class="u-reset-button" @tap="submit">提交出库</button>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			dataArr: [], // 商品列表
			clientInfo: {} //客户信息
		};
	},
	onLoad() {
		this.dataArr = uni.getStorageSync('dataArr') || [];
		this.clientInfo = uni.getStorageSync('clientInfo') || {};
		console.log('dataArr',this.dataArr.length)
		console.log('clientInfo',this.clientInfo.length)
		if(this.dataArr.length === 0){
			//console.log('客户信息或商品信息缺失，请返回重新录入')
			this.$u.toast('客户信息或商品信息缺失，请返回重新录入');
			this.$Router.push('/pages/product/outbound/index');
		}
	},
	methods: {
		submit(){
			let that = this;
			that.$http('goods.depotConfirm', {
				clientInfo: that.clientInfo,
				params: that.dataArr
			}).then(res => {
				that.$u.toast(res.msg);
				if(res.code === 1) {
					that.$Router.push('/pages/product/outbound/result');
				}
				uni.removeStorageSync('dataArr');
				uni.removeStorageSync('clientInfo');
			})
		},
	}
};
</script>

<style lang="scss" scoped>
.item {
	 margin-bottom: 30rpx;
}

.footer {
	position: fixed;
	right: 0;
	bottom: 0;
	left: 0;
	padding: 20rpx;
	background-color: #fff;
	.text {
		font-size: 28rpx;
		color: #E77817;
	}
	.u-reset-button {
		flex: 1;
		color: #fff;
		font-size: 28rpx;
		height: 80rpx;
		line-height: 80rpx;
		border-radius: 20rpx;
		background-color: #E77817;
	}
}
</style>